GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#709)
by Jesus
38:17 queued 33:16
created

user_edit.js ➔ clearRole   B

Complexity

Conditions 8

Size

Total Lines 24
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 8
c 0
b 0
f 0
dl 0
loc 24
rs 7.3333
eloc 12
1
// BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
2
//
3
// Copyright (c) 2018 BigBlueButton Inc. and by respective authors (see below).
4
//
5
// This program is free software; you can redistribute it and/or modify it under the
6
// terms of the GNU Lesser General Public License as published by the Free Software
7
// Foundation; either version 3.0 of the License, or (at your option) any later
8
// version.
9
//
10
// BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
11
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12
// PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
13
//
14
// You should have received a copy of the GNU Lesser General Public License along
15
// with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
16
17
$(document).on('turbolinks:load', function(){
18
    var controller = $("body").data('controller');
19
    var action = $("body").data('action');
20
    if ((controller == "admins" && action == "edit_user") || (controller == "users" && action == "edit")) {
21
        $(".setting-btn").click(function(data){
22
            var url = $("body").data("relative-root")
23
            if (!url.endsWith("/")) {
24
                url += "/"
25
            }
26
            url += "admins?setting=" + data.target.id
27
28
            window.location.href = url
29
        })
30
31
        // Clear the role when the user clicks the x
32
        $(".clear-role").click(clearRole)
33
34
        // When the user selects an item in the dropdown add the role to the user
35
        $("#role-select-dropdown").change(function(data){
36
            var dropdown = $("#role-select-dropdown");
37
            var select_role_id = dropdown.val();
38
39
            if(select_role_id){
40
                // Disable the role in the dropdown
41
                var selected_role = dropdown.find('[value=\"' + select_role_id + '\"]');
42
                selected_role.prop("disabled", true)
43
44
                // Add the role tag
45
                var tag_container = $("#role-tag-container");
46
                tag_container.append("<span id=\"user-role-tag_" + select_role_id + "\" style=\"background-color:" + selected_role.data("colour") + ";\" class=\"tag\">" + 
47
                    selected_role.text() + "<a data-role-id=\"" + select_role_id + "\" class=\"tag-addon clear-role\"><i data-role-id=\"" + select_role_id + "\" class=\"fas fa-times\"></i></a></span>");
48
49
                // Update the role ids input that gets submited on user update
50
                var role_ids = $("#user_role_ids").val()
51
                role_ids += " " + select_role_id
52
                $("#user_role_ids").val(role_ids)
53
                
54
                // Add the clear role function to the tag
55
                $("#user-role-tag_" + select_role_id).click(clearRole);
56
57
                // Reset the dropdown
58
                dropdown.val(null)
59
            }
60
        })
61
    }
62
})
63
64
// This function removes the specfied role from a user
65
function clearRole(data){
66
    // Get the role id
67
    var role_id = $(data.target).data("role-id");
68
    var role_tag = $("#user-role-tag_" + role_id);
69
70
    // Remove the role tag
71
    $(role_tag).remove()
72
  
73
    // Update the role ids input
74
    var role_ids = $("#user_role_ids").val()
75
    var parsed_ids = role_ids.split(' ')
76
  
77
    var index = parsed_ids.indexOf(role_id.toString());
78
  
79
    if (index > -1) {
80
        parsed_ids.splice(index, 1);
81
    }
82
  
83
    $("#user_role_ids").val(parsed_ids.join(' '))
84
  
85
    // Enable the role in the role select dropdown
86
    var selected_role = $("#role-select-dropdown").find('[value=\"' + role_id + '\"]');
87
    selected_role.prop("disabled", false)
88
}